﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NFAPI
{
    public static class EnumHelper
    {
        private static Dictionary<Type, Dictionary<string, object>> _mappings =
            new Dictionary<Type, Dictionary<string, object>> {
                { typeof(Format), new Dictionary<string,object> {
                    { "DVD", Format.DVD },
                    { "Instant", Format.Instant }
                }},

                { typeof(Availability), new Dictionary<string,object> {
                    { "available now", Availability.Now },
                    { "awaiting release", Availability.AwaitingRelease },
                    { "saved", Availability.Saved }
                }},

                { typeof(Rating), new Dictionary<string,object> {
                    { "UR", Rating.UR },
                    { "R", Rating.R },
                    { "PG", Rating.PG },
                    { "G", Rating.G },
                    { "NC-17", Rating.NC17 },
                    { "PG-13", Rating.PG13 },
                    { "TV-PG", Rating.TVPG },
                    { "TV-MA", Rating.TVMA },
                    { "NR", Rating.NR },
                    { "TV-14", Rating.TV14 }
                }}};
                

        public static object GetValue(Type enumType, string item)
        {
            if (_mappings[enumType].ContainsKey(item))
                return _mappings[enumType][item];
            return null;
        }
    }
}
